package cz.khfotbal.beans;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import cz.khfotbal.domain.Season;
import cz.khfotbal.service.SeasonService;

@Component
@Scope(value = "session")
public class SeasonBean {

	@Autowired
	private SeasonService seasonService;

	private Season newSeason;
	private Season selectedSeason;

	public SeasonBean() {
		newSeason = new Season();
	}

	public List<Season> getSeasonList() {
		return seasonService.getAllSeasons();
	}

	public void updateSeason() {
		if (selectedSeason != null) {
			seasonService.updateSeason(selectedSeason);
		}
		newSeason = new Season();
	}

	public void createSeason() {
		seasonService.createSeason(newSeason);
		newSeason = new Season();
	}

	public Season getNewSeason() {
		return newSeason;
	}

	public void setNewSeason(Season newSeason) {
		this.newSeason = newSeason;
	}

	public Season getSelectedSeason() {
		return selectedSeason;
	}

	public void setSelectedSeason(Season selectedSeason) {
		this.selectedSeason = selectedSeason;
	}

}
